import h5py
import numpy as np
from config import Config
config = Config()

regions_list = []
for x in range(-10, 10, int(20*config.win_img)):
    for y in range(-10, 10, int(20*config.win_img)):
        regions_list.append([x*1.0/10,y*1.0/10])
regions = np.array(regions_list)

def transform(regions,index):
    return regions[index]


indexes=np.array(h5py.File('train.h5','r').get('index'))



locs=np.zeros((indexes.shape[0],indexes.shape[1],2))

for i in range(indexes.shape[0]):
    for j in range (indexes.shape[1]):
           locs[i,j]=transform(regions,indexes[i,j])

with h5py.File('./train.h5', 'r+') as hf:
          hf.create_dataset('locs', data=np.array(locs))
